package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.hfinterface.SecondHandItemClickCall;
import com.kmproject.haifu.mvp.model.entity.beans.SecondHandTreeTypeBean;

import java.util.List;

public class SecondhandPublicshSelectTypeItemAdapter extends BaseQuickAdapter<SecondHandTreeTypeBean, BaseViewHolder> {
    int selectSexIndex=-1;
    SecondHandItemClickCall mSecondHandItemClickCall;
    public SecondhandPublicshSelectTypeItemAdapter(@Nullable List<SecondHandTreeTypeBean> data,SecondHandItemClickCall secondHandItemClickCall) {
        super(R.layout.secondhand_publicsh_selecttype_item_item, data);
        mSecondHandItemClickCall=secondHandItemClickCall;
    }

    @Override
    protected void convert(BaseViewHolder helper, SecondHandTreeTypeBean item) {
        helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_item_txt).setText(item.getName());
        helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_item_txt).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectSexIndex=helper.getPosition();
                notifyDataSetChanged();
            }
        });
     if (selectSexIndex==helper.getAdapterPosition())
     {
         helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_item_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
         helper.<ImageView>getView(R.id.secondhand_publicsh_selecttype_item_item_img).setVisibility(View.VISIBLE);
         mSecondHandItemClickCall.call(item);
     }else {

         helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_item_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_747474));
         helper.<ImageView>getView(R.id.secondhand_publicsh_selecttype_item_item_img).setVisibility(View.GONE);
     }
    }
}
